<script setup lang="ts">
import {ref,watch} from 'vue';
let text =ref("")
const jinci=["你","我","他"]

let isRed=ref(false)
watch(
    ()=>text.value,(newVlue,oldVlue)=>{
        jinci.forEach(s=>{
            if(newVlue.includes(s)){
            isRed.value=true;
            // let hefa_text=newVlue.substring(0,newVlue.length -1);
            // text.value=hefa_text;
            // alert("您回复中包含了违禁词")
            }
        })

    }
)
</script>
<template>
<div>
    <input type="text" placeholder="请输入合法字符"v-model=text  class="input_bg_yellow":class="{input_bg_red:isRed}"/>
</div>
</template>
<style scoped>
.input_bg_yellow{
    background-color: rgb(255, 255, 255);
}
.input_bg_red{
    background-color: red;
}
</style>